package config

import (
	"fmt"
	"github.com/spf13/viper"
)

type Mysql struct {
	User     string
	Password string
	Host     string
	Port     int
	Database string
}
type Redis struct {
	Addr     string
	Password string
	DB       int
}
type ViperData struct {
	Mysql
	Redis
}

var AppViperData ViperData

func GetViperData() {
	viper.SetConfigFile("./config/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic("配置文件读取失败")
	}
	err = viper.Unmarshal(&AppViperData)
	if err != nil {
		panic("配置文件解析失败")
	}
	fmt.Println(AppViperData)
	fmt.Println("配置文件读取成功")
}
